Git(hub)

Help

Help


Version Control to the Rescue!

  • Example: this presentation

xccd

xccd


Adding and Staging Area

Staging Area

Staging Area

Commit

  • Commit saves Changes from the previous commit
    • changes in files
    • newly created files
    • deletion of files
    • changes in filenames
  • a commit can entail multiple changes

Go back in time!

Time Machine

Time Machine


Go back in time

@ol

  • reset master to this commit
  • spiele mit: hard, mixed, soft
  • fast forward master to origin/master (oberster commit) git reset HEAD~ git add …
    git commit -c ORIG_HEAD

@olend

(Source: https://git-scm.com/about/staging-area)


Worklfow

Lokal

Lokal


Making a commit

Grace + Mona

@ol

  • Change stuff!
  • GIT ADD “Unstaged Files”
  • write a (fairly) commit message
  • GIT COMMIT

@olend


Git Hosting

  • Cloud! For example:

@fa [gitlab] @fa [github]


Git Local and Git Remote

… what?

Lokal: your PC Remote: in the Cloud (GitHub, GitLab, …)

Gitkraken Lokal Remote

Gitkraken Lokal Remote


Sync data - Push und Pull


Sync: Git Pull und Git Push

  • Git Pull: download new commits from GitHub
  • Git Push: push locally made commits to GitHub

Sync: Git Pull and Git Push

Push Pull

Push Pull


Push the button

Push the button


Pull and Push

@ol

  • Grace: Push
  • Mona: Pull
  • Mona: Push
  • Grace: Pull

@olend


Push and Pull

Push Pull

Push Pull


When things go wrong…


git google

git google


Git stash

stash

stash

–> put it away for now!


Git stash bei merge conflicts

@ol

  • git stash
  • git pull
  • apply stash
  • solve merge conflicts
  • (delete stash)

@olend


Hands on 5: Merge conflicts


mit GitHub arbeiten


Issues

@ul

  • issues: Todos / Bugs / Ideas
  • every issue has a number
  • #issueno in commit message links message to commit

@ulend


Hands On 4: Issue

@ol

  • Mona: Issue erstellen: “Grace’s LieblingsGIF fehlt”
  • Grace: füge der Präsentation eine neue Folie hinzu mit deinem Lieblingsgif (giphy -> copy link)
  • Grace: add + commit. verlinke issue Nummer in der commit message (#issueno)
  • Grace: push
  • Mona: Issue neu laden (STRG+R)

@olend


Branches


[picture of complicated gitkraken with a lot of branches]


Come on

Come on


Why branches?

@ul

  • keep “master” branch free of “unfinished” code
  • independent creation of code (“feature branches”)
  • experiments

@ulend


Branches Workflow

@ol

  • Branch erstellen
  • normal weiterarbeiten (pull-commit-push cycles)
  • (optional: merge andere branches in deinen branch um Updates zu bekommen)
  • merge Branch in master branch

@olend


Merging branches

  • Rechtsclick auf branch name / master
  • hängt davon ab, wer “weiter vorne” ist (?)
    • wenn neue commits auf master: merge master into #1-add-branch-slides -> branch wird geupdatet
    • wenn neue commits auf branch: merge #1-add-branch-slides into master -> master wird geupdatet

Branches Fazit

@ul

  • useful if working across different teams
  • Example: developing packages
  • For Data Analytics / Data Science projects?

@ulend


Download the data - Fork und Clone


Fork und Clone

@boxbg-blue text-black rounded

@box[bg-blue text-black rounded](Fork#“A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.” (Source)


Save Data - Add and Commit



Commit history

Git commits

Git commits


How do we want to use it?

  • command line

When things go wrong…

@ol

  • so lange nichts gepusht ist, alles (halbwegs) gut
    • oft committen!
  • zur Not: Codestand sichern und neu clonen

@olend

Hands On 1 - Fork und Clone

Mona

@ol

@olend


Hands On 1 - Fork und Clone

Mona & Grace

Git clone

Git clone

@ol

  • Gitkraken Clone Repo -> Clone with URL
  • Kopierten Link unter URL eintragen

@olend


Oh!

Git clone error

Git clone error


Oh! - Nicht-Gitkraken

Cloning into 'git-our-shit-together'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

SSH

@ul

  • Download:
    • prinzipell jede*r @fa [lock-open] über https –> @fa [github]: @fa [check]
    • ssh: vorherige Einrichtung ntowendig –> @fa [github]: @fa [question]
  • Upload: nur authentifizierte Personen @fa [lock]
  • –> @fa [github]: @fa [question]

@ulend


Authentification - Passwort

  • bei jedem Push GitHub Passwort eingeben
  • beachte: clone https://...
Git clone

Git clone


Authentification - SSH

  • public key, private key cryptography (see: Youtube)
  • only authenticate once->
  • clone ssh://...

Hands On 1.1: Gitkraken mit Github verbinden

@ol

  • Gitkraken Profil (rechts oben)
  • Preferences->Authentification->GitHub
  • connect to GitHub
  • Generate SSH key and add to GitHub

@olend


Thats it. Thank you!

stash

stash

gerne den Tag über fragen!